Title: Tech 101: Snownews
Date: 2017-06-10
Modified: 2017-12-07
Category: Blog
Slug: tech-101-snownews
Tags: tech-101, cli, howto
Summary: Proper care and feeding of your CLI feed reader

So, to kick this blog off to a fun start, I'm going to announce a new series (or
rather, related posts) called Tech 101. This is designed to be an
introduction/how-to for using some pieces of technology (mostly software) that I
have found useful, but that might be a bit hard to figure our or
unapproachable for people who are trying it for the first time. Today, we're
gonna talk about [Snownews][1], which is a command-line feed reader. Snownews is
surprisingly effective at what it does, while being quite lightweight
resource-wise as well.

## What on earth is a feed reader? ##

Anyone who spends any amount of time on the Internet knows that content can be a
pain to keep track of. You'll often have sites (blogs, news sites, possibly
other stuff) with content that renews periodically. Sometimes, those periods are
predictable; sometimes, they're not. Once you get beyond just a few of these,
you commonly end up with a few problems:

1. You end up spam-checking the site in question just in case something new came
   up. This is great for their advertising, but not so much for your time - you
   end up doing this habitually or just because you're bored, wasting valuable
   productive hours.
1. If the site has a lot of content on it, it might be worth keeping track of
   what you've looked at and what remains. You may not have enough time to
   go through ten new articles - it'd be good to just read two, but then still
   know which ones you've missed.
1. Having everything in one place is easier; instead of having to navigate to
   multiple pages or services, you can just find them all in one spot.
1. You don't have to rely on stuff that you don't control (beyond the fact that
   the content is hosted elsewhere). Youtube is a great example of this - a
   reason many people have Google+ accounts is just so they can monitor their
   favourite channels. With a feed reader, this becomes unnecessary (and
   frankly, the more people ditch Google+, the better).

Feed readers are designed to solve all of the above. Essentially, they do a 
simple job: given a list of places to 'watch', they monitor for when they
have new content, and let you know where and what it is, as well as having links
to it. By simply loading up all of this stuff into such a program, you can now
go about your day, not having to worry whatsoever about missing a thing. You can
also concentrate all of your content-browsing into one or two times a day, and
you never have to worry about losing your place or forgetting what you have and
haven't seen. 

Sounds pretty good? I certainly think so - I'm not sure where I'd be if I
couldn't use feed readers. While they're certainly not without their downsides,
feed readers help keep you more focused, more productive, and in my opinion,
more sane. Snownews is a really good example of such a feed reader, due to its
simplicity, flexibility and lack of bloat.

## Why CLI? ##

Command-line applications have a bit of a bad rep in some areas; they're
considered to be hard to learn, hard to use, and generally unsightly. I disagree
with that - I believe that command-line applications can actually be easier to
use, easier to learn, and considerably more powerful than graphical ones for
many tasks. On top of that, a command-line interface (CLI) doesn't burn up
insane resources, and doesn't require you to even have a monitor connected to
the computer on which you run them. This allows you to trivially work with them
remotely, without relying on someone else's (probably proprietary, probably
surveillance-loaded, and probably awful) service via the web.

Snownews has a pleasant CLI, with a lot of help when you need it. If you've
never used a CLI application before, Snownews is a really good way to get into
it.

## Getting started with Snownews ##

> "OK Koz, I get it - Snownews is amazing! Tell me how to do stuff with it
already!"

First-off, you'll need to install it. If you're on a Linux-based something or a
BSD, you can easily do this via your package manager; if you're on a Mac, I
would suggest learning how to [Homebrew][2]; if you're on Windows, first,
my sympathies, and secondly, Snownews won't work for you, so consider switching
to something better!

Once you've installed Snownews, just run it from a terminal with the
``snownews`` command. You'll be presented with a big empty window. If so -
great! One useful thing to note - if you're ever not clear how to do something,
just press the ``h`` key to bring up a nice help window, which will likely
resolve 90% of your issues.

Let's get some content going. When we add some feeds, they'll appear in
this main window. However, adding them is a little bit trickier, because we need
a helper program to do it. For now, exit out of Snownews using ``q``. The
program you will need is [curl][3], which is a helper for downloading almost
anything. We will use it to fetch content for us. Once again, getting it set up
shouldn't be a problem on anything where Snownews will run. To make sure it
works once you've installed it, type the following into the terminal:

``curl retro-freedom.nz``

If you get HTML in your terminal, then everything is fine. Get back into
Snownews; it's time to add our first feed. We're going to add the feed for
[Everyday Feminism][4] so that we can keep track of their interesting and
educational articles. To do so, we need to find their RSS feed page. This is
quite easy to do: just view their home page source, search for the string 'rss', 
and you'll see the link there. What we need to do is tell Snownews how we go
about fetching it. To do that, we need to use the ``exec`` command in the pop-up
we got from pressing ``a``. Specifically, we want to write the following:

``exec:curl http://feeds.feedburner.com/EverydayFeminism``

This tells Snownews something like "to fetch this feed, run the command after
the colon". This can be arbitrary shell code - you can use your own scripts if
you want, as long as the result produces a feed that Snownews can make sense of.
After we've entered that, press the ``Enter`` key, and Snownews will add the
feed. It will now show up on the main screen, with the default 10 new entries
marked as unread. To read the feed, just highlight it with the arrow keys, then
press ``Enter``. To go back, press ``q``. It's really easy! You'll now have the
ability to see what new content has appeared there, in reverse-chronological
order (i.e. newest first), along with links.

Once you've read everything, you may want to refresh feeds periodically. You can
do that per-feed using ``r`` (which will refresh the highlighted feed) or ``R``
to refresh all of them!

## Going further with feeds ##

Unfortunately, Snownews cannot read every type of feed - it can handle RSS, but
not Atom. Luckily, we can get around that problem pretty easily. Just like
Snownews can execute arbitrary commands to *retrieve* feeds and content, it can
also execute arbitrary commands on the result of whatever it fetched. As with
the previous issue of getting feeds to us, we're going to need a helper program
for this called ``xsltproc``. It shouldn't be hard to retrieve, just like
previously. Make sure you have it set up before we start.

To help us
work with Atom feeds, we're going to use a script called ``atom2rss``, written
by the kind René Puls. You can find the text of the script [here][5], or
practice your ``curl`` by doing the following (all one line):

``curl https://gist.githubusercontent.com/kianga/dfae790d788005fe319d9dc6c7bda818/raw/51c178168da06044f1afbf0efbd7d11fcdf81410/atom2rss.xsl > atom2rss``

Make sure you remember where you put the script - you're going to need it for
the next part. Let's now add our second feed, this time for [Eevee's blog][6],
for his hilarious take on technology, games and many other things besides. Press
``a``, then enter

``exec:curl https://eev.ee/feeds/blog.atom.xml``

Snownews won't be happy with that, but it will ask us if we want a filter
script. Press ``y``, then enter the following:

``xsltproc /path/to/atom2rss -``

That dash is important, so don't omit it! With that, you'll notice that we've
now added Eevee's blog feed without any issues. In general, if you're having
trouble adding a feed, try sending it through ``atom2rss`` - it'll fix most
issues. 

## Turning Youtube into feeds ##

Now let's do something a bit more interesting - use Snownews to monitor Youtube
channels, or even individual playlists of those channels. First-off, we need to
know how to get RSS feeds from Youtube channels and playlists. The former is
surprisingly easy: go to the channel page, view its source, and search for the
string 'rss' - you'll find the link there. You will need to use ``atom2rss`` on
it, and now, you will have a way of knowing when the next [Wanda Melodious][7]
video featuring her unique brand of feminist critique of mid-to-late-90s JRPGs
will be up!

Following individual playlists like this is harder, but still possible. Let's
suppose you wanted to follow [The Jimquisition][8] - Jim Sterling's teardown of
games media, games publishers and shittiness in the game industry. However,
you're not quite so interested in Jim making fun of awful games, so you want to
just hear about The Jimquisition. Using [the method described here][9], we can
get a feed for just that playlist; to add it, use the following (all one line):

``exec:curl https://www.youtube.com/feeds/videos.xml?playlist_id=PLlRceUcRZcK0E1Id3NHchFaxikvCvAVQe``

You'll need to pass it through ``atom2rss`` as well. Now, you have all the
benefits of Google+ for Youtube, without the EULAs, surveillance and other
awfulness. Isn't it great?

## Going further ##

With the combination of Snownews and command-line tools, you can do some amazing
things. Check out [the helper script repository for Snownews][10] for ideas!
I hope that it will be as useful to you as it is to me. If you wanna get started,
[why not follow my feed][11]?

[1]: https://github.com/kouya/snownews 
[2]: https://brew.sh/
[3]: https://curl.haxx.se/
[4]: http://everydayfeminism.com/
[5]: https://gist.githubusercontent.com/kianga/dfae790d788005fe319d9dc6c7bda818/raw/51c178168da06044f1afbf0efbd7d11fcdf81410/atom2rss.xsl
[6]: https://eev.ee/blog/ 
[7]: https://www.youtube.com/user/Jaydencats/featured
[8]: https://www.youtube.com/playlist?list=PLlRceUcRZcK0E1Id3NHchFaxikvCvAVQe
[9]: https://webapps.stackexchange.com/questions/79131/get-an-rss-feed-for-a-youtube-playlist/79294#79294
[10]: https://github.com/kouya/snownews/tree/master/contrib
[11]: https://retro-freedom.nz/rss.xml
